<?php
function navi() {
global $wp_query;
$max_page = $wp_query->max_num_pages;
$nump=4;
if($max_page > 1) echo '<div class="navigation">';
if ($max_page!=1) {
$paged = intval(get_query_var('paged'));
if(empty($paged) || $paged == 0) $paged = 1;
if($paged!=1)echo '<a href="'.get_pagenum_link($paged-1).'" class="prev" title="Previous">&laquo;</a>';
if($paged!=1) echo '<a href="'.get_pagenum_link(1).'">1</a>';
else echo '<span class="current">1</span>';
if($paged-$nump>1) $start=$paged-$nump; else $start=2;
if($paged+$nump<$max_page) $end=$paged+$nump; else $end=$max_page-1;
if($start>2) echo " ... ";
for ($i=$start;$i<=$end;$i++) {
$zero = '';
if($i < '10') $zero = '';
if($paged!=$i) echo '<a href="'.get_pagenum_link($i).'">'.$zero.$i.'</a>';
else echo '<span class="current">'.$zero.$i.'</span>';
}
if($end<$max_page-1) echo " ... ";
if($paged!=$max_page) echo '<a href="'.get_pagenum_link($paged+1).'" class="next" title="Next">&raquo;</a>';
if($paged!=$max_page) echo '<a href="'.get_pagenum_link($max_page).'" class="last" title="Last">&raquo;&raquo;</a>';
else echo '<span class="current">'.$max_page.'</span>';
}
if($max_page > 1) echo '</div>';
}
?>